package edu.chds.ui
{
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.net.URLRequest;

	public class ImageLoader extends MovieClip
	{
		public var bg:MovieClip;
		private var _loader:Loader;
		private var _loaderWidth:Number;
		private var _loaderHeight:Number;
		
		public function ImageLoader(w:Number=77, h:Number=98)
		{
			init();
			_loaderWidth = w;
			_loaderHeight = h;
		}
		private function init():void {
			bg = imageLoaderBG;
			this.width = _loaderWidth;
			this.height = _loaderHeight;	
		}
		public function load(path:String):void {
			_loader = new Loader();
			_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
			_loader.load(new URLRequest(path));
		}
		private function thumbLoaded(e:Event):void {
			_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded);
			this.addChild(_loader);
			this.setChildIndex(_loader, this.numChildren - 2);
		}
	}
}